﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QUANLYNHASACH
{
    public class Random
    {
        private static string CreateCode(string current_code, string chars_start)
        {
            try
            {
                string str, result = ""; int number;
                str = current_code.Substring(chars_start.Length);
                number = Convert.ToInt32(str) + 1;
                for (int i = 0; i < str.Length - number.ToString().Length; i++)
                    result += "0";
                result = chars_start + result + number.ToString();
                return result;
            }
            catch (Exception)
            {
                return null;
            }
        }

        //Random mã hàng cung cấp
        public static string AutoCodeChiTietHCC(string code)
        {
            return CreateCode(code, "MACTHCC");
        }

        public static string AutoCodeChiTietHCC1(string code)
        {
            return CreateCode(AutoCodeChiTietHCC(code), "MACTHCC");
        }

        //Random STT
        public static int AutoCodeSTT(string code) 
        {
            int number;
            number = Convert.ToInt32(code) + 1;
            return number;
        }
    }
}
